//---------------------------------------------------------------------------
// CShellProcess
// Author : Woo-Hyun Kim
// Email : woorung@icu.ac.kr
// Date : Jul. 7, 2006
//---------------------------------------------------------------------------
#include "CShellProcess.h"

CShellProcess::CShellProcess() : CProcess()
{
	command = "";
}

CShellProcess::CShellProcess(string &comm) : CProcess()
{
	command = comm;
}

CShellProcess::CShellProcess(int verbose) : CProcess(verbose)
{
	command = "";
}

CShellProcess::CShellProcess(string &comm, int verbose) : CProcess(verbose)
{
	command = comm;
}

CShellProcess::~CShellProcess() 
{
}

int CShellProcess::read_upstream(const char *buf) 
{
	cout << buf;

	return 1;
}

int CShellProcess::read_upstream(const void *buf, size_t size) 
{
	for(size_t i=0;i<size;i++) cout << *((char *)buf + i);

	return 1;
}

int CShellProcess::read_downstream(const char *buf) 
{
}

int CShellProcess::read_downstream(const void *buf, size_t size) 
{
}

int CShellProcess::read_errstream(const char *buf) 
{
	cerr << buf;

	return 1;
}

int CShellProcess::read_errstream(const void *buf, size_t size) 
{
	for(size_t i=0;i<size;i++) cerr << *((char *)buf + i);

	return 1;
}

void CShellProcess::set(string &comm) 
{ 
	command = comm;
}

string &CShellProcess::get() 
{ 
	return command; 
}

void CShellProcess::before_run() 
{
	//write_downstream("woorung nara\n");
};

void CShellProcess::run() 
{
	system((char *)command.c_str());
}
